<?php
class Nadeb_Twitter extends Nadeb_Twitter_Manipulation
{
	private $usr;
	private $psw;
	
	public function __construct($_usr = null,$_psw = null)
	{
		$this->usr = $_usr;
		$this->psw = $_psw;
	}
	

	public function get_userTimeline($_limit = 5)
	{
		$method = $this->get_xml_method('user_timeline',$_limit);
		
		return $method;
	}
	
	public function get_homeTimeline($_limit = 5)
	{
		$method = $this->get_xml_method('home_timeline',$_limit);
		
		return $method;
	}
	
	public function get_friendsTimeline($_limit = 5)
	{
		$method = $this->get_xml_method('friends_timeline',$_limit);
		
		return $method;
	}
	
	public function get_publicTimeline($_limit = 5)
	{
		$method = $this->get_xml_method('public_timeline',$_limit);
		
		return $method;
	}
	/**
	 * Retorna um metodo especifico da API Twitter
	 * @see http://apiwiki.twitter.com/Twitter-API-Documentation
	 * 
	 * @param $_method nome do metodo a ser requisitado
	 * @return xml
	 */
	
	private function get_xml_method($_method, $_limit)
	{
		$login  = "$this->usr:$this->psw";
		$tweets = "http://twitter.com/statuses/$_method.xml?count=$_limit";
		
		$tw = curl_init();
		
		curl_setopt($tw, CURLOPT_URL, $tweets);
		curl_setopt($tw, CURLOPT_USERPWD, $login);
		curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
		
		$twi = curl_exec($tw);
		return $twi;
	}
	
	
	
}